import _axios from '@/tool/http.js'
import { DRcookie } from '@/assets/js/common.js'

// 获取计划购买时间
export const getPlanTime = () => {
    let options = {
        url: api.base + '/systemDictionary/getByType/planBuyTime',
        method: 'POST',
        headers: {
            "Content-Type": 'application/json', "Accept": 'application/json'
        }
    }
    return _axios(options);
}
// 获取预约客户的列表
export const getPendingOrders = (obj) => {
    let options = {
        url: api.crm + '/reservationInfo/list',
        method: 'POST',
        data: JSON.stringify(obj),
        headers: {
            "Content-Type": 'application/json', "Accept": 'application/json'
        }
    }
    return _axios(options)
}
// 货物预约来源
export const getResource = () => {
    let options = {
        url: api.base + '/systemDictionary/getByType/reservationSource',
        method: 'POST',
        headers: {
            "Content-Type": 'application/json', "Accept": 'application/json'
        }
    }
    return _axios(options);
}
// 创建预约
export const createOrder = (param) => {
    let options = {
        url: api.crm + '/reservationInfo/add',
        method: 'POST',
        data: JSON.stringify(param),
        headers: {
            "Content-Type": 'application/json', "Accept": 'application/json'
        }
    }
    return _axios(options)
}
// 编辑预约
export const modifyOrder = (param) => {
    let options = {
        url: api.crm + '/reservationInfo/edit',
        method: 'POST',
        data: JSON.stringify(param),
        headers: {
            "Content-Type": 'application/json', "Accept": 'application/json'
        }
    }
    return _axios(options)
}
export const findStaffByName = (name) => {
    let options = {
        url: api.crm + '/reservationInfo/findSupportStaff?name=' + name,
        method: 'GET',
        headers: {
            "Content-Type": 'application/json', "Accept": 'application/json'
        }
    }
    return _axios(options)
}
// 获取客服信息
export const getStaffInfo = (id) => {
    let options = {
        url: api.crm + '/reservationInfo/getSupportStaff?parentId=' + id,
        method: 'GET',
        headers: {
            "Content-Type": 'application/json', "Accept": 'application/json'
        }
    }
    return _axios(options)
}
// 获取每种情况的数量
export const getCount = () => {
    let options = {
        url: api.crm + '/reservationInfo/getCount' ,
        method: 'GET',
        headers: {
            "Content-Type": 'application/json', "Accept": 'application/json'
        }
    }
    return _axios(options)
}
// 指派
export const doDistribute = (param) => {
    let options = {
        url: api.crm + '/reservationAssign/assign',
        method: 'POST',
        data: JSON.stringify(param),
        headers: {
            "Content-Type": 'application/json', "Accept": 'application/json'
        }
    }
    return _axios(options)
}
// 获取预约审批失败原因
export const getFaildReason = () => {
    let options = {
        url: api.base + '/systemDictionary/getByType/failedType',
        method: 'POST',
        headers: {
            "Content-Type": 'application/json', "Accept": 'application/json'
        }
    }
    return _axios(options)
}
// 获取预约审批失败原因
export const getWastedReason = () => {
    let options = {
        url: api.base + '/systemDictionary/getByType/disabledType',
        method: 'POST',
        headers: {
            "Content-Type": 'application/json', "Accept": 'application/json'
        }
    }
    return _axios(options)
}
// 验证手机号/快捷查询
export const checkPhone = (phone, type) => {
    let options = {
        url: api.crm + `/reservationInfo/getByPhone?phone=${phone}&type=${type}`,
        method: 'GET',
        headers: {
            "Content-Type": 'application/json', "Accept": 'application/json'
        }
    }
    return _axios(options);
}
// 获取当前门店/地址
export const getCurrentShop = () => {
    let shopCode = DRcookie.get('shopCode')
    let options = {
        url: api.crm + '/reservationInfo/getShop/' + shopCode,
        method: 'GET',
        headers: {
            "Content-Type": 'application/json', "Accept": 'application/json'
        }
    }
    return _axios(options);
}
// 所有客服
export const getFollowUpList = () => {
    let options = {
        url: api.base + '/systemUser/get',
        method: 'POST',
        headers: {
            "Content-Type": 'application/json', "Accept": 'application/json'
        },
        data: JSON.stringify({})
    }
    return _axios(options)
}